﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AddDutyType.aspx.cs" Inherits="ZX.WebApp.EditWidows.OrganizationalManager.AddDutyType" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/yahoo-dom-event/yahoo-dom-event.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/connection/connection-min.js"></script>
    <script src="../../Scripts/jquery-1.6.min.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery.json-2.2.min.js" type="text/javascript"></script>
    <script src="../../Scripts/Jquery.form.js" type="text/javascript"></script>
    <link href="../../Styles/extendTable.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table class="tableContent" id="dutyTypeTable">
            <tr>
                <td style="height:30px; width:60px;">
                    &nbsp;名称
                </td>
                <td>
                    <input type="text" id="PhraseText" name="PhraseText" maxlength="50" runat="server" />
                    <span style="color: Red">*</span>
                </td>
            </tr>
            <tr>
                <td style="height:30px; width:60px;">
                    &nbsp;顺序号</td>
                <td>
                    <input type="text" id="Seq" name="Seq" 
                        onkeyup="this.value=this.value.replace(/\D/g,'')" 
                        onafterpaste="this.value=this.value.replace(/\D/g,'')"
                        runat="server" />
                    <span style="color: Red">*</span>
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
<script type="text/javascript">
    var Id = "<%=TypeId %>",Entity="<%=EntityNames %>";
    var ListInfo = [<%=ListTypeInfo %>],Url="";
    var instance = [{ "PhraseText": "", "Seq": ""}];
    function Save() {
        var vName = document.getElementById("PhraseText").value;
        var vSequenceNo = document.getElementById("Seq").value;
        if (vName == "" || vName == null) {
            alert("名称不能为空!");
            document.getElementById("PhraseText").focus();
            return;
        } else if (vSequenceNo == "" || vSequenceNo == null) {
            alert("顺序号不能为空!");
            document.getElementById("Seq").focus();
            return;
        } else {
            $("#dutyTypeTable").SetFormValueToObject(instance[0]);
            var json = $.toJSON(instance[0]).replace(/'/g, "[B]");
            if(Id==""){
                Url="DataProcessin.aspx?entity="+Entity+"&action=Insert&json=" + encodeURI(json);
            }else{
                Url="DataProcessin.aspx?entity="+Entity+"&action=Update&json=" + encodeURI(json) +"&id=" + Id;
            }
            SaveData();
        }
    }
    function SaveData(){
        YAHOO.util.Connect.asyncRequest('POST', Url, {
            success: function (res) {
                var inventory;
                try {
                    inventory = res.responseText;
                    if (inventory == 1) {
                        alert("保存成功!");
                        parent.LoadData();
                        parent.closeWin(2);
                    } else {
                        alert(inventory);
                    }
                }
                catch (e) {
                }
                finally {
                }
            },
            failure: function (error) {
                alert("数据错误：" + error.statusText);
            }
        }, null);
    }
</script>
</html>
